################################################################################
# GraphNode and Edge classes
################################################################################

class GraphNode
  attr_reader :letter
  attr_reader :edges # list of Edges
  
  def initialize(letter)
    @letter = letter
    @edges = []
  end
  
  def add_node(node, distance)
    edge = Edge.new(node, distance)
    @edges.push(edge)
  end
  
  # other GraphNode
  def eql?(other)
    letter.eql?(other.letter)
  end
  
  def to_s
    letter
  end
end

class Edge
  attr_accessor :node #GraphNode
  attr_accessor :distance
  
  def initialize(node, distance)
    @node = node
    @distance = distance
  end
  
  def to_s
    "node(#{@distance})"
  end  
end